﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TJDevHouse.Starcraft.Game;

namespace TJDevHouse.Starcraft.MapAnalyser
{
	public class MapAnalysisController
	{
		static private Dictionary<int, MapAnalysisController> _mapControllers = new Dictionary<int, MapAnalysisController>();

		/// <summary>
		/// Get the analyser for the supplied map.
		/// 
		/// Ensures that only one controller per map is created.
		/// 
		/// </summary>
		/// <param name="map"></param>
		/// <returns></returns>
		static public MapAnalysisController GetMapAnalysisController(Map map)
		{
			if (!_mapControllers.ContainsKey(map.MapHash))
			{
				_mapControllers.Add(map.MapHash, new MapAnalysisController(map));
			}
			return _mapControllers[map.MapHash];
		}

		/// <summary>
		/// The map to be analysed
		/// </summary>
		public Map Map { get; private set; }

		/// <summary>
		/// Analyser to report on different walkability zones
		/// </summary>
		public Analysers.WalkabilityAnalyser WalkabilityAnalyser { get; private set; }

		/// <summary>
		/// Provides path finding functionality
		/// </summary>
		public PathFinder PathFinder { get; private set; }

		private MapAnalysisController(Map map)
		{
			Map = map;
			WalkabilityAnalyser = new TJDevHouse.Starcraft.MapAnalyser.Analysers.WalkabilityAnalyser(Map, this);
			PathFinder = new PathFinder(Map, this);
		}

	}
}